// $Id$
// Licensed under Apache License Version 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0.html
package de.servicezombie.tcmdb.rest.vo;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.StringUtils;

@XmlRootElement(name = "execution")
@XmlAccessorType(XmlAccessType.FIELD)
public class WsTestExecution extends WsTestcaseDefinition {

	public static final String UNKNOWN_GROUP = "unknown-group";

	/**
	 * @notNull
	 */
	@XmlElement(name = "referenceDefinitionId")
	private String referencedDefinitionId;

	@XmlElement(name = "responsibleTester")
	private WsAuthor responsible;

	/**
	 * a string representing to which test cycle this execution belongs
	 */
	@XmlElement(name = "group")
	private String group;

	@XmlElement(name = "executionEffort")
	private WsEffort executionEffort;

	@XmlElement(name = "affectedVersion")
	private String affectedVersion;

	@XmlElement(name = "remark")
	private String remark;

	/**
	 * e.g. OPEN, OK, FAIL, FIXED, SKIPPED, KNOWN_BUG
	 */
	@XmlElement(name = "resolution")
	private String resolution;

	public String getReferencedDefinitionId() {
		return referencedDefinitionId;
	}

	public void setReferencedDefinitionId(String referencedDefinitionId) {
		this.referencedDefinitionId = referencedDefinitionId;
	}

	public WsAuthor getResponsible() {
		return responsible;
	}

	public void setResponsible(WsAuthor responsible) {
		this.responsible = responsible;
	}

	public String getGroup() {
		if (group == null) {
			group = UNKNOWN_GROUP;
		}
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public WsEffort getExecutionEffort() {
		if(executionEffort == null) {
			executionEffort = new WsEffort();
		}
		return executionEffort;
	}

	public void setExecutionEffort(WsEffort realEffort) {
		this.executionEffort = realEffort;
	}

	public String getAffectedVersion() {
		return affectedVersion;
	}

	public void setAffectedVersion(String affectedVersion) {
		this.affectedVersion = affectedVersion;
	}

	public String getExecutionRemark() {
		return remark;
	}

	public void setExecutionRemark(String remark) {
		this.remark = remark;
	}

	public String getResolution() {
		if(resolution == null) {
			resolution = StringUtils.EMPTY;
		}
		return resolution;
	}

	public void setResolution(String resolution) {
		this.resolution = resolution;
	}

}
